package main

import "fmt"

type Person struct {
	id   int
	name string
	sex  string
	age  int
	addr string
}

func main0801() {
	var per Person = Person{101, "宇智波佐助", "男", 16, "木叶村"}
	//p := &per
	var p *Person = &per
	(*p).name = "旋涡鸣人"
	// 指针可以直接操作结构体成员
	p.age = 17
	p.id = 123
	fmt.Println(per)
}

func test4(p *Person) {
	p.addr = "斯塔克公司"
}

func main0802() {
	var per Person = Person{101, "钢铁侠", "男", 180, "武当山"}
	// 地址传递 形参可以改变实参的值
	test4(&per)
	fmt.Println(per)
}

func main() {
	m := make(map[int]*[3]Person)
	m[1] = new([3]Person)
	m[1] = &[3]Person{{101, "钢铁侠", "男", 180, "斯塔克公司"},
		{102, "雷神", "男", 1500, "阿斯加德"},
		{103, "黑寡妇", "女", 23, "前苏联"}}
	m[2] = new([3]Person)
	m[2] = &[3]Person{{101, "钢铁侠", "男", 180, "斯塔克公司"},
		{102, "雷神", "男", 1500, "阿斯加德"},
		{103, "黑寡妇", "女", 23, "前苏联"}}

	for k, v := range m {
		fmt.Println(k, *v)
	}
}
